/* sctw.t  SIMULATION COST TOTAL DETAIL WRITE TRIGGER                 */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :sctw.t                                                  */
/*  Author  :Pat Pigatti                                             */
/*  Date    :7/29/98                                                 */
/*  !Description : sct_det WRITE trigger program                     */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.6       Last Modified:  07/29/98 BY: *M009* Pat Pigatti */
/*Revision 9.1       Last Modified:  08/12/00 BY: *N0KN* myb          */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

TRIGGER PROCEDURE FOR WRITE OF SCT_DET OLD BUFFER OLD_SCT_DET.

/* *M009* New Section Added for Logistics Use of this trigger. */
    {mfdeclre.i }
    
    define new shared work-table wf_old_sct_det like sct_det.
/*fdn*********************************************
    define work-table wf_old_sct_det like sct_det.
***fdn********************************************/    
    define variable w-rowid as recid.

/* Logistics Interface processing */
    LG:
    do:
/* If there is no logistics application ID, then do not process */
         if not can-find(first lgs_mstr no-lock
           where lgs_app_id <> "")
           then leave LG.

/* If no pertinent fields have been changed, then do not process */
         if (old_sct_det.sct_cst_tot <> sct_det.sct_cst_tot) then do:

 /* Move old pt_mstr values to work table for subsequent processing */
            assign w-rowid = recid(sct_det).
            create wf_old_sct_det.
            if recid(wf_old_sct_det)= -1 then .
            buffer-copy
                old_sct_det  to wf_old_sct_det no-error.

/* Call subprogram to publish changed status for Logistics */
               {gprunmo.i &module="LG"
                &program="lgsctexa.p"
                &param="""(input w-rowid)"""}
         end.
      end. /* LG */
/* *M009* *End of Added Section */

	/* fdn 2004/10/28 Modify Record processing */
	HK:
	do:
        if not can-find ( first dt_mstr where dt_table = "sct_det" and dt_type = "MOD" ) then leave HK.
        
        if not can-find ( first wf_old_sct_det ) then do:
            create wf_old_sct_det.
            if recid(wf_old_sct_det)= -1 then .
        end.
        
        buffer-copy old_sct_det to wf_old_sct_det no-error.

        for each dt_mstr no-lock where dt_table = "sct_det" and dt_type = "MOD" :
        
        	run value(global_user_lang_dir + "hk/hktrigmod.p")
       			"wf_old_sct_det"		/*old buffer*/
       			"sct_det"				/*new buffer*/
       			dt_table				/*table name*/
       			dt_field				/*field name*/
       			dt_type					/*type*/
       			recid(sct_det)			/*key*/	
       			sct_det.sct_sim			/*key1*/
       			sct_det.sct_part		/*key2*/
       			sct_det.sct_site		/*key3*/
       			""						/*key4*/
       			""						/*key5*/
       			""						/*key6*/
       			""						/*key7*/
       			""						/*key8*/
       			.
			
        end.
	end.
